//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package study.IO.字符流;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class copeDirectory {
    public copeDirectory() {
    }

    public static void main(String[] args) throws IOException {
        File arc = new File("JavaTest\\Files");
        File dest = new File("JavaTest\\dest");
        Copy(arc, dest);
    }

    private static void Copy(File arc, File dest) throws IOException {
        dest.mkdirs();
        File[] fl = arc.listFiles();
        if (fl != null) {
            for(File f : fl) {
                if (!f.isFile()) {
                    Copy(f, new File(dest, f.getName()));
                } else {
                    byte[] bytes = new byte[5120];
                    FileInputStream in = new FileInputStream(f);
                    FileOutputStream out = new FileOutputStream(new File(dest, f.getName()));

                    int len;
                    while((len = in.read(bytes)) != -1) {
                        out.write(bytes, 0, len);
                    }

                    in.close();
                    out.close();
                }
            }
        }

    }
}
